package com.anivia.common.core.enums;

import com.anivia.common.core.constant.PlatformTypeConstant;
import com.baomidou.mybatisplus.annotation.EnumValue;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
 * 平台类型
 *
 * @author wangj
 */
@AllArgsConstructor
@NoArgsConstructor
@Getter
public enum PlatformTypeEnum implements BaseEnum {
    /**
     * a端
     */
    ADMIN(1, PlatformTypeConstant.ADMIN, "a端"),
    /**
     * b端
     */
    TENANT(2, PlatformTypeConstant.TENANT, "b端"),
    /**
     * 展业
     */
    USER(3, PlatformTypeConstant.USER, "展业"),
    ;

    @EnumValue
    private Integer code;
    private String type;
    private String desc;

    public String toString() {
        return name() + "-" + getDesc();
    }

    public static PlatformTypeEnum getByType(String type) {
        for (PlatformTypeEnum enumItem : values()) {
            if (enumItem.type.equals(type)) {
                return enumItem;
            }
        }
        return null;
    }


    public static PlatformTypeEnum getByCode(Integer code) {
        for (PlatformTypeEnum enumItem : values()) {
            if (enumItem.code.equals(code)) {
                return enumItem;
            }
        }
        return null;
    }
}
